﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<!-- bootstrap css-->
<link href="web/listbox/css/bootstrap.min.css"  rel="stylesheet" 
media="screen">
<!-- bootstrap table css -->
<link rel="stylesheet" href="web/table/bootstrap-table.min.css" />

<!-- 设置该iframe中的背景色 与父页面一致-->
<style type="text/css" >
body { background:#f5f5f5  }
</style>
</head>
<body >
   
    
<div class="container">
  <div class="panel panel-primary">
    <div class="panel-heading">
          <h3 class="panel-title">
              药师资格审核 
          </h3>
   </div>
   
   
   <div class="panel-body">

    <div id="toolbar"> 
        <button id="accept" class="btn btn-danger" disabled>
            通过
        </button>
         <button id="noaccept" class="btn btn-danger " disabled>
             不通过
        </button>
        
    </div>

    
    <table id="table"
           data-toolbar="#toolbar"
           data-id-field="id"
           data-url="admin/getUncheckedDoctor"
		   data-page-list="[10]"
		   data-show-refresh="true" 
           data-pagination="true" 
           data-response-handler="responseHandler"  
           >

    </table>

	</div>
 
 </div>





<!-- bootstrap js -->
<script src="web/vendors/jquery-1.9.1.min.js"></script>
<script src="web/listbox/js/bootstrap.min.js"></script>



<!-- bootstrap table js-->
<script src="web/table/bootstrap-table.min.js"></script>

<!-- layer  js-->
<script src="web/layer/layer.js"></script>

<script>

	    var $table = $('#table'),
		$accept = $('#accept'),
	    $noaccept = $('#noaccept'),
	    selections = []; 
	
		 
	   window.operateEvents  = {

					'click .doctorDiploma': function (e, value, row, index) {
						
						//console.log( row.doctorDiploma);
 						layer.open({
 						    type: 1,
 						    shade: [0],
 						    area: ['500px', '400px'],
 						    offset: [ '50px'], 
 						    title: false,
 						    border: [0],
 						    content: "<div><img src='diplomaUpload/"+row.doctorDiploma+"'/></div>"
 						    
 						});
					}
  		  };
		 
		 
		 
		 
        $("#accept,#noaccept").click(function () {
            var ids = getIdSelections();
			var url = "admin/action/"+$(this).attr("id");
			//ajax
			$.post(url,{"ids":ids },function(res){
				//当服务器返回ok时 
				if(res.status == 'ok'){
				$table.bootstrapTable('remove', {
					  field: 'doctorId',
					  values: ids
				});
				$("#accept,#noaccept").prop('disabled' ,true);
				
	 
				}
			});
			
		});
		
	 


	

	 $('#table').bootstrapTable({
				columns: [	
				
				{
					field:'state',
					checkbox:true,
					valign:'middle',
					align:'center'
				},
				{
					field: 'doctorId',
					title: 'id',
					valign:'middle',
					align:'center'
				}, {
					field: 'doctorName',
					title: '申请人',
					valign:'middle',
					align:'center'
				}, {
					field: 'doctorUnit',
					title: '单位',
					valign:'middle',
					align:'center'
				} 
				,{
					field: 'doctorTitles',
					title: '职称',
					valign:'middle',
					align:'center'
				},{
					field: 'opterate',
					title: '操作',
					formatter : operateFormatter,
					events : operateEvents,
					valign:'middle',
					align:'center'
				},{
					field: 'doctorDiploma',
					valign:'middle',
					align:'center',
					visible:false
				}
				],
				sidePagination: "server"
				,
				clickToSelect: true
		});
	
         setTimeout(function () {
            $table.bootstrapTable('resetView');
         }, 200);
		 
		
	   	 function operateFormatter(value, row, index){
			
			var res = [];
			
			res.push(
			' <a class="doctorDiploma" href="javascript:void(0)" title="执照">'
            +'	<i class="glyphicon glyphicon-credit-card"></i>' 
            +' </a>'
            ); 
			
            
    	 	return res.join('');
	  	 }
		 
		
		
		
		
        $table.on('check.bs.table uncheck.bs.table ' +
                'check-all.bs.table uncheck-all.bs.table', function () {
            $noaccept.prop('disabled', !$table.bootstrapTable('getSelections').length);
			$accept.prop('disabled', !$table.bootstrapTable('getSelections').length);
            // save your data, here just save the current page

            selections = getIdSelections(); 
            // push or splice the selections if you want to save all data selections
        });
    	
		


		 

		

		
		function getHeight() {
			return $(window).height() - $('h1').outerHeight(true);
		}
		
        $(window).resize(function () {
            $table.bootstrapTable('resetView', {
                height: getHeight()
            });
        });
		
		function getIdSelections() {
			return $.map($table.bootstrapTable('getSelections'), function (row) {
				return row.doctorId
			});
		}
		function responseHandler(res) {

			return res;
		}

	
		
		

</script>
</body>
</html>